home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWUtil.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  10.0 KB  |  286 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWUtil.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWUTIL_H
  13. #include "FWUtil.h"
  14. #endif
  15.  
  16. #ifndef FWACQUIR_H
  17. #include "FWAcquir.h"
  18. #endif
  19.  
  20. #ifndef FWPOINT_H
  21. #include "FWPoint.h"
  22. #endif
  23.  
  24. #ifndef FWRECT_H
  25. #include "FWRect.h"
  26. #endif
  27.  
  28. #ifndef SOM_ODStorageUnit_xh
  29. #include <StorageU.xh>
  30. #endif
  31.  
  32. #ifndef SOM_ODFacet_xh
  33. #include <Facet.xh>
  34. #endif
  35.  
  36. #ifndef SOM_Module_OpenDoc_Errors_defined
  37. #include <ErrorDef.xh>
  38. #endif
  39.  
  40. //========================================================================================
  41. // Runtime Informations
  42. //========================================================================================
  43.  
  44. #ifdef FW_BUILD_MAC
  45. #pragma segment framework
  46. #endif
  47.  
  48. //========================================================================================
  49. //    Storage Unit Utilities
  50. //========================================================================================
  51.  
  52. //----------------------------------------------------------------------------------------
  53. // FW_SUAddPropValue
  54. //----------------------------------------------------------------------------------------
  55.  
  56. void FW_SUAddPropValue(Environment* ev, ODStorageUnit* su, ODPropertyName prop, ODValueType val)
  57. {
  58.     if (!su->Exists(ev, prop, NULL, 0))
  59.     {
  60.         su->AddProperty(ev, prop)->AddValue(ev, val);
  61.     }
  62.     else
  63.     {
  64.         su->Focus(ev, prop, kODPosUndefined, NULL, 0, kODPosUndefined);
  65.         if (!su->Exists(ev, prop, val, 0))
  66.             su->AddValue(ev, val);
  67.     }
  68. }
  69.  
  70. //----------------------------------------------------------------------------------------
  71. //    FW_IsInLimbo
  72. //----------------------------------------------------------------------------------------
  73. // [HLX] I have to put a try block because of a bug in OpenDoc 1.0
  74.  
  75. FW_Boolean FW_IsInLimbo(Environment* ev, ODFrame* frame)
  76. {
  77.     FW_Boolean result = FALSE;
  78.     FW_TRY
  79.     {
  80.         result = frame->IsInLimbo(ev);
  81.     }
  82.     FW_CATCH_BEGIN
  83.     FW_CATCH_EVERYTHING () 
  84.     {
  85.         if (FW_GetEvError(ev) != kODErrInvalidFrame)            
  86.             FW_THROW_SAME ();
  87.     }
  88.     FW_CATCH_END    
  89.     
  90.     return result;
  91. }
  92.  
  93. //========================================================================================
  94. //    Content to Frame and Frame to Content coordinate conversions
  95. //========================================================================================
  96.  
  97. //----------------------------------------------------------------------------------------
  98. // FW_ContentToFrame
  99. //----------------------------------------------------------------------------------------
  100.  
  101. void FW_ContentToFrame(Environment* ev, ODFrame* frame, ODShape* shape)
  102. {
  103.     FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
  104.     shape->Transform(ev, transform);
  105. }
  106.  
  107. //----------------------------------------------------------------------------------------
  108. // FW_FrameToContent
  109. //----------------------------------------------------------------------------------------
  110.  
  111. void FW_FrameToContent(Environment* ev, ODFrame* frame, ODShape* shape)
  112. {
  113.     FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
  114.     shape->InverseTransform(ev, transform);
  115. }
  116.  
  117. //----------------------------------------------------------------------------------------
  118. // FW_ContentToFrame
  119. //----------------------------------------------------------------------------------------
  120.  
  121. void FW_ContentToFrame(Environment* ev, ODFrame* frame, FW_CPoint& point)
  122. {
  123.     FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
  124.     point.Transform(ev, transform);
  125. }
  126.  
  127. //----------------------------------------------------------------------------------------
  128. // FW_FrameToContent
  129. //----------------------------------------------------------------------------------------
  130.  
  131. void FW_FrameToContent(Environment* ev, ODFrame* frame, FW_CPoint& point)
  132. {
  133.     FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
  134.     point.InverseTransform(ev, transform);
  135. }
  136.  
  137. //----------------------------------------------------------------------------------------
  138. // FW_ContentToFrame
  139. //----------------------------------------------------------------------------------------
  140.  
  141. void FW_ContentToFrame(Environment* ev, ODFrame* frame, FW_CRect& rect)
  142. {
  143.     FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
  144.     rect.Transform(ev, transform);
  145. }
  146.  
  147. //----------------------------------------------------------------------------------------
  148. // FW_FrameToContent
  149. //----------------------------------------------------------------------------------------
  150.  
  151. void FW_FrameToContent(Environment* ev, ODFrame* frame, FW_CRect& rect)
  152. {
  153.     FW_CAcquiredODTransform transform = frame->AcquireInternalTransform(ev, NULL);
  154.     rect.InverseTransform(ev, transform);
  155. }
  156.  
  157. //========================================================================================
  158. //    Content to Window and Window to Content coordinate conversions
  159. //========================================================================================
  160.  
  161. //----------------------------------------------------------------------------------------
  162. // FW_ContentToWindow
  163. //----------------------------------------------------------------------------------------
  164.  
  165. void FW_ContentToWindow(Environment* ev, ODFacet* facet, ODShape* shape)
  166. {
  167.     FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
  168.     shape->Transform(ev, transform);
  169. }
  170.  
  171. //----------------------------------------------------------------------------------------
  172. // FW_WindowToContent
  173. //----------------------------------------------------------------------------------------
  174.  
  175. void FW_WindowToContent(Environment* ev, ODFacet* facet, ODShape* shape)
  176. {
  177.     FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
  178.     shape->InverseTransform(ev, transform);
  179. }
  180.  
  181. //----------------------------------------------------------------------------------------
  182. // FW_ContentToWindow
  183. //----------------------------------------------------------------------------------------
  184.  
  185. void FW_ContentToWindow(Environment* ev, ODFacet* facet, FW_CPoint& point)
  186. {
  187.     FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
  188.     point.Transform(ev, transform);
  189. }
  190.  
  191. //----------------------------------------------------------------------------------------
  192. // FW_WindowToContent
  193. //----------------------------------------------------------------------------------------
  194.  
  195. void FW_WindowToContent(Environment* ev, ODFacet* facet, FW_CPoint& point)
  196. {
  197.     FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
  198.     point.InverseTransform(ev, transform);
  199. }
  200.  
  201. //----------------------------------------------------------------------------------------
  202. // FW_ContentToWindow
  203. //----------------------------------------------------------------------------------------
  204.  
  205. void FW_ContentToWindow(Environment* ev, ODFacet* facet, FW_CRect& rect)
  206. {
  207.     FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
  208.     rect.Transform(ev, transform);
  209. }
  210.  
  211. //----------------------------------------------------------------------------------------
  212. // FW_WindowToContent
  213. //----------------------------------------------------------------------------------------
  214.  
  215. void FW_WindowToContent(Environment* ev, ODFacet* facet, FW_CRect& rect)
  216. {
  217.     FW_CAcquiredODTransform transform = facet->AcquireWindowContentTransform(ev, NULL);
  218.     rect.InverseTransform(ev, transform);
  219. }
  220.  
  221. //========================================================================================
  222. //    Frame to Window and Window to Frame coordinate conversions
  223. //========================================================================================
  224.  
  225. //----------------------------------------------------------------------------------------
  226. // FW_FrameToWindow
  227. //----------------------------------------------------------------------------------------
  228.  
  229. void FW_FrameToWindow(Environment* ev, ODFacet* facet, ODShape* shape)
  230. {
  231.     FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
  232.     shape->Transform(ev, transform);
  233. }
  234.  
  235. //----------------------------------------------------------------------------------------
  236. // FW_WindowToFrame
  237. //----------------------------------------------------------------------------------------
  238.  
  239. void FW_WindowToFrame(Environment* ev, ODFacet* facet, ODShape* shape)
  240. {
  241.     FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
  242.     shape->InverseTransform(ev, transform);
  243. }
  244.  
  245. //----------------------------------------------------------------------------------------
  246. // FW_FrameToWindow
  247. //----------------------------------------------------------------------------------------
  248.  
  249. void FW_FrameToWindow(Environment* ev, ODFacet* facet, FW_CPoint& point)
  250. {
  251.     FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
  252.     point.Transform(ev, transform);
  253. }
  254.  
  255. //----------------------------------------------------------------------------------------
  256. // FW_WindowToFrame
  257. //----------------------------------------------------------------------------------------
  258.  
  259. void FW_WindowToFrame(Environment* ev, ODFacet* facet, FW_CPoint& point)
  260. {
  261.     FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
  262.     point.InverseTransform(ev, transform);
  263. }
  264.  
  265. //----------------------------------------------------------------------------------------
  266. // FW_FrameToWindow
  267. //----------------------------------------------------------------------------------------
  268.  
  269. void FW_FrameToWindow(Environment* ev, ODFacet* facet, FW_CRect& rect)
  270. {
  271.     FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
  272.     rect.Transform(ev, transform);
  273. }
  274.  
  275. //----------------------------------------------------------------------------------------
  276. // FW_WindowToFrame
  277. //----------------------------------------------------------------------------------------
  278.  
  279. void FW_WindowToFrame(Environment* ev, ODFacet* facet, FW_CRect& rect)
  280. {
  281.     FW_CAcquiredODTransform transform = facet->AcquireWindowFrameTransform(ev, NULL);
  282.     rect.InverseTransform(ev, transform);
  283. }
  284.  
  285.  
  286.